/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dbHandling;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author Hans
 */
public class CategoryHandler {

    private DatabaseConnect dbc;

    public CategoryHandler(DatabaseConnect dbc) {
        this.dbc = dbc;
    }

    public ArrayList<String> getCategories() throws SQLException, ClassNotFoundException {
        ArrayList<String> categories = new ArrayList<>();
        String sql = "SELECT `name` FROM `klodshans`.`Category`;";
//        String sql = "SELECT name FROM Category";

        ResultSet rs = dbc.readFromDatabase(sql);

        while (rs.next()) {
            categories.add(rs.getString("name"));
        }
        return categories;
    }

}
